import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TableVO, TableForm, TableQuery } from '@/api/demo/table/types';

/**
 * 查询测试单列表
 * @param query
 * @returns {*}
 */
export const listTable = (query?: TableQuery): AxiosPromise<TableVO[]> => {
  return request({
    url: '/demo/table/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询测试单详细
 * @param id
 */
export const getTable = (id: string | number): AxiosPromise<TableVO> => {
  return request({
    url: '/demo/table/' + id,
    method: 'get'
  });
};

/**
 * 新增测试单
 * @param data
 */
export const addTable = (data: TableForm) => {
  return request({
    url: '/demo/table',
    method: 'post',
    data: data
  });
};

/**
 * 修改测试单
 * @param data
 */
export const updateTable = (data: TableForm) => {
  return request({
    url: '/demo/table',
    method: 'put',
    data: data
  });
};

/**
 * 删除测试单
 * @param id
 */
export const delTable = (id: string | number | Array<string | number>) => {
  return request({
    url: '/demo/table/' + id,
    method: 'delete'
  });
};
